home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 October
/
Ahoy_Magazine_85-10_1985_Double_L.d64
/
radioactive dec.
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
51 lines
0 print"[147]":poke53280,0:poke53281,6:poke646,1
1 rem
2 rem * radioactive decay *
3 rem rupert report #22
4 rem
5 rem monte carlo simulation of a
6 rem two-product decay chain
7 rem
10 ttl=100 :rem initial number
20 sf=22/ttl :rem plot scale factor
30 nd=2 :rem number of daughters
40 dim nuc(ttl)
100 rem decay constants
110 dc(0)=.2
120 dc(1)=.05 :rem first daughter
130 dc(2)=0 :rem stable isotope
140 m(0)=ttl :rem initial amount
150 print chr$(147)" =-= radioactive decay =-="
160 for t=1 to 20
170 gosub 400 :rem <<< gosub 500 to plot
180 for n=1 to ttl
190 if rnd(0) > dc(nuc(n)) then 220
200 k=nuc(n) : nuc(n)=k+1
210 m(k)=m(k)-1 : m(k+1)=m(k+1)+1
220 next n
230 next t
240 poke 214,23 : print
250 poke 211,12
260 print"=press a key to continue==>";
270 get a$ : if a$="" then 270
280 goto 150
390 end
395 rem --- print value routine ---
400 print tm ">>",
410 for j=0 to nd
420 print m(j),:next j
430 tm=tm+1
440 return
495 rem
499 rem ---- plot routine ----
500 for j=0 to nd
510 y=m(j) : s$=right$(str$(j),1)
520 row%=22-sf*y : col%=2*t-2
530 if row%>23 then row%=23
540 if row%<=0 then row%=0
550 if col%>38 then col%=38
560 if col%<0 then col%=0
570 poke 214,row%: print
580 poke 211,col%: print s$
590 next j : return